﻿using System;
using System.Collections.Generic;
using System.Data;
using DAL;
using Entities;

namespace BLL
{
    public class BLL_Advertise
    {
        private DAL_Advertise dal_Advertise = new DAL_Advertise();

        public DataTable Get_Advertise_All()
        {
            return dal_Advertise.Get_Advertise_All();
        }

        public DataTable Get_Advertise(Int64 pID)
        {
            return dal_Advertise.Get_Advertise(pID);
        }

        public DataTable Get_Advertise_Dynamic(string pCondition)
        {
            return dal_Advertise.Get_Advertise_Dynamic(pCondition);
        }

        public List<Advertise> Lst_Advertise(DataTable pdt)
        {
            List<Advertise> lstReturn = new List<Advertise>();
            if (pdt != null && pdt.Rows.Count > 0)
            {
                foreach (DataRow dr in pdt.Rows)
                {
                    Advertise advertise = new Advertise();
                    advertise.NAME = Convert.ToString(dr["NAME"]);
                    advertise.ID = (dr["ID"] == DBNull.Value ? 0 : Convert.ToInt32(dr["ID"]));
                    advertise.IMAGE_DIRECTORY = Convert.ToString(dr["IMAGE_DIRECTORY"]);
                    advertise.SEQUENCE = (dr["SEQUENCE"] == DBNull.Value ? 0 : Convert.ToInt32(dr["SEQUENCE"]));
                    advertise.WEB_LINK = Convert.ToString(dr["WEB_LINK"]);
                    lstReturn.Add(advertise);
                }
            }
            return lstReturn;
        }

        public bool InsertUpdate_Advertise(Advertise pAdvertise)
        {
            return dal_Advertise.InsertUpdate_Advertise(pAdvertise);
        }

        public Int64 Get_Advertise_MaxID()
        {
            return dal_Advertise.Get_Advertise_MaxID();
        }

        public bool DeleteAdvertise(Int64 pID)
        {
            return dal_Advertise.DeleteAdvertise(pID);
        }
    }
}
